package com.example.jeecgboot.controller;

import com.example.jeecgboot.entity.UserEntity;
import com.example.jeecgboot.utils.RedisUtils;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @version: java version 23
 * @Author: 韩学新
 * @description:
 * @date: 2025-05-26 上午11:22
 */
@RestController
public class RedisController {

    @Resource
    private RedisUtils redisUtils;

    @PostMapping("/addUser")
    public String addUser(@RequestBody UserEntity userEntity) {
        redisUtils.setObject("userEntity", userEntity);
        return "存储成功";
    }

    @RequestMapping("/getUser")
    public UserEntity getUser(String key) {
        return (UserEntity) redisUtils.getObject(key);
    }
}
